<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>跑马灯</title>
</head>
<body>
    <div id="app">
        <button @click = 'start'>开始</button>
        <button @click = 'stop'>停止</button>
        <p v-text = 'msg'></p>
    </div>
</body>
<script src="../js/vue.js"></script>
<script>
    let app = new Vue({
        el:'#app',
        data:{
            msg:'吴浩想吃屁！！！',
            intervalID:null
        },
        methods:{
            start(){
                clearInterval(this.intervalID)
                this.intervalID = setInterval(() => {
                    let start = this.msg.substring(0,1)
                    let end = this.msg.substring(1)
                    this.msg = end + start
                }, 400);
            },
            stop(){
                clearInterval(this.intervalID)
                this.intervalID = null
            }
        }
    })
</script>
</html>